<!DOCTYPE html>
<title>Test that video play does not work unless a user gesture is involved in playing a video.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-controls.js"></script>
<script>
internals.settings.setAutoplayPolicy('user-gesture-required');
</script>
<video controls></video>
<script>
async_test(function(t) {
    var userGestureInitiated = false;
    var video = document.querySelector("video");

    video.oncanplaythrough = t.step_func(function() {
        // No user gesture initiated.
        video.play();
        assert_true(video.paused);

        // User gesture initiated.
        userGestureInitiated = true;
        var playCoords = elementCoordinates(enabledPlayButton(video));
        eventSender.mouseMoveTo(playCoords[0], playCoords[1]);
        eventSender.mouseDown();
        eventSender.mouseUp();
    });

    video.onplaying = t.step_func(function() {
        assert_true(userGestureInitiated);
        video.pause();
    });

    video.onpause = t.step_func_done(function() {
        assert_true(video.paused);
    });

    video.src = "content/test.ogv";
});
</script>
